import { defineStore } from 'pinia';
export const useUserStore = defineStore('user', {
  state: () => {
    return {
      username: 'John Doe',
      age: 30,
      isLoggedIn: false
    }
  },
  getters: {
    info: (state) => {
      return `${state.username} ${state.age}`;
    }
  },
  actions: {
    login() {
      //发送网络请求
      this.isLoggedIn = true;
    },
    logout() {
      //发送网络请求
      this.isLoggedIn = false;
    },
    updateUsername(newUsername) {
      this.username = newUsername;
    }
  }
});